import { reqSort } from '../../apis/index'

// pages/category/category.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: 0,
    sortArr: [] 
  },

  changeActive(e){
    this.setData({
      active: e.currentTarget.dataset.index
    })
  },

  onLoad(){
    this.getReqSort()
  },

  // 获取分类层级数据
  async getReqSort(){
    const res = await reqSort()
    if(res.code === 200) {
      this.setData({
        sortArr: res.data
      })
    }
  },

  //去商品分类页面
  findGoods(e){
    const { category2id } = e.currentTarget.dataset
    wx.navigateTo({
      url: `/pages/goods/goods?category2Id=${category2id}`
    })
  }
})